package com.ftn;

import java.awt.*;

/**
 * User: Jack Fu
 * Date: 2024/9/6
 * Time: 15:03
 * To change this template use File | Settings | File Templates.
 * Description:
 */
public class Boss2BulletObj extends GameObj{

    int removeX = -2500;

    @Override
    public void paintSelf(Graphics g) {
        y += speed;

        // 与飞机子弹碰撞，都消失
        for (ShellObj shellObj : GameUtils.shellObjs) {
            if (this.getRec().intersects(shellObj.getRec())) {
                // 添加爆炸对象
                ExplodeObj explodeObj = new ExplodeObj(this.getX(), this.getY());
                GameUtils.explodeObjs.add(explodeObj);
                GameUtils.removeObjs.add(explodeObj);

                // 现将元素移除到界面之外
                shellObj.setX(removeX);
                this.setX(removeX);

                GameUtils.removeObjs.add(shellObj);
                GameUtils.removeObjs.add(this);

                GameWin.score += 4;
            }
        }

        if (this.getY() > 1000) {
            GameUtils.removeObjs.add(this);
        }

        super.paintSelf(g);
    }

    @Override
    public Rectangle getRec() {
        return super.getRec();
    }

    public Boss2BulletObj() {
    }

    public Boss2BulletObj(int x, int y) {
        super(x, y);
    }

    public Boss2BulletObj(int x, int y, int width, int height, Image image, int speed, GameWin gameWin) {
        super(x, y, width, height, image, speed, gameWin);
    }

    public Boss2BulletObj(int x, int y, Image image, int speed) {
        super(x, y, image, speed);
    }
}
